/**
 * Copyright (C) 2009 aileron.cc
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package cc.aileron.text;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import org.junit.Test;
import org.junit.runner.RunWith;

import cc.aileron.junit.runner.guice.GuiceInjectRunner;
import cc.aileron.junit.runner.guice.GuiceInjectRunnerModule;
import cc.aileron.text.logic.TextLogic;
import cc.aileron.text.model.Message;
import cc.aileron.text.model.UriKey;
import cc.aileron.wsgi.test.WsgiTestModule;

import com.google.inject.Inject;

/**
 * @author Aileron
 */
@GuiceInjectRunnerModule(value = WsgiTestModule.class, arg = "env.properties")
@RunWith(GuiceInjectRunner.class)
public class TryTextLogic
{
    /**
     * get
     */
    @Test
    public void get()
    {
        final Message message = logic.get(new UriKey("10ljagZ48TmCxiyU"));
        System.out.println(message);
    }

    /**
     * 保存のテスト
     */
    @Test
    public void save()
    {
        final Message message = new Message();
        message.string("testest");

        logic.write(message);

        final Message result = logic.get(message.uriKey);
        assertThat(result, notNullValue());
        assertThat(result.id, is(message.id));
    }

    @Inject
    private TextLogic logic;
}
